#include "header.h"
#include "str.h"


int NickIsValid (char* nick)
/*
	
*/
{
 int len = strlen (nick),
     count;

	for (count=0; count<len; count++)
		if (!isLetter(nick[count]))
			return -1;

 return 0;
}

int Strncmp (char* s1, const char* s2)
{
	unsigned int len = strlen (s1);

		if (len != strlen (s2))
			return -1;

 return (strncmp (s1, s2, len));
}

char *strLowerCase (char *string, int length)
{
 int i;

	for (i=0; i<length; i++)
		string[i] = tolower (string[i]);

 return string;
}

int parseMsg (char *buffer,  Message *msg)
/*
	
*/
{
 int nbr;
 char *ptr = NULL;

	if (buffer != NULL){
		nbr = sscanf (buffer, "%30s", msg->cmd);
			if (nbr == 1){
				strLowerCase (msg->cmd, strlen (msg->cmd));
				ptr = strchr (buffer, ' ');
				if (ptr != NULL){
					ptr++;
					nbr = sscanf (ptr, "%480[^\n]", msg->tail);
					return 0;
				}
			}
		return -1;
	}

 return -1;
}

